import request from '@/utils/request'

export function Get(id, args) {
  return request({
    url: `/erp/api/product/${id || ''}${args && ('?' + args) || ''}`,
    method: 'get'
  })
}

export function Post(data) {
  return request({
    url: '/erp/api/product/',
    headers: { 'content-type': 'application/json' },
    method: 'post',
    data: data
  })
}

export function Put(id, data) {
  return request({
    url: `/erp/api/product/${id || ''}`,
    headers: { 'content-type': 'application/json' },
    method: 'put',
    data: JSON.stringify(data)
  })
}

export function Delete(id) {
  return request({
    url: `/erp/api/product/${id || ''}`,
    method: 'delete'
  })
}

export function GetTree(catalog_id, args) {
  return request({
    url: `/erp/api/elicink/product_tree/${catalog_id || ''}${args && ('?' + args) || ''}`,
    method: 'get'
  })
}

export function dt(data) {
  return request({
    url: '/erp/api/product/dt',
    method: 'post',
    data: data,
    timeout: 40000
  })
}

export function product_export(data) {
  return request({
    url: '/erp/api/product_export/',
    headers: { 'content-type': 'application/json' },
    method: 'post',
    data: JSON.stringify(data),
    timeout: 500000
  })
}

export function product_remote_edit(data) {
  return request({
    url: '/erp/api/product_batch_edit/',
    headers: { 'content-type': 'application/json' },
    method: 'post',
    data: JSON.stringify(data),
    timeout: 500000
  })
}

export function ProductQuery(data) {
  return request({
    url: '/erp/api/product/query/',
    method: 'post',
    data: data
  })
}
